<template>
	<view>
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="content">老师资料</block>
		</cu-custom>
		<view class="persomfir solid-bottom">
			<view>老师资料</view>
		</view>
		<view class="personProfile" style="background-color: #FFFFFF;">
			<view class="profileList flex">
				<view>姓名{{join_token}}</view>
				<input class="input-box" placeholder="请输入真实姓名" v-model="teacher_name"/>
			</view>
			<!-- <view class="profileList flex">
				<view>手机号</view>
				<input class="input-box" placeholder="请输入电话号码" v-model="phone"/>
			</view> -->
			
		</view>
		<view class="buttomBut">
			<button @tap="request" style="width: 335rpx; height: 80rpx; line-height: 80rpx; background-color: #3b73f6; border-radius: 50rpx;">
				<text style="color: #ffffff; font-size: 30rpx;">加入</text>
			</button>
		</view>
	</view>
</template>

<script>
	const {appLogin,httpGet,httpPost,msg,ZC} = require("@/utils/common.js")
	export default {
		data() {
			return {
				join_token:'',
				teacher_name:'',
				school_teacher_join_token:''
				
			}
		},
		onLoad(option) {
			this.getschool()
			if(option.teachjoin_token){
				ZC('join_token',option.teachjoin_token,-1)
				this.join_token = option.teachjoin_token
			}
			appLogin((user_info)=>{
				console.log(user_info)
				if(!this.teachjoin_token)this.teachjoin_token = ZC('join_token')
			})
		},
		methods: {
			request(){
				if(!this.teacher_name){
					uni.showToast({
						title:'请输入老师姓名',
						duration: 2000,
						icon:'none'
					});
					return;
				}
				httpPost({
					url:'/api/school/teacher_join',
					data:{
						join_token:this.join_token,
						teacher_name:this.teacher_name,
					}
				}).then((res)=>{
					console.log(res)
					this.student_join_token = res.result.student_join_token
					msg('加入成功',()=>{
						uni.navigateTo({
							url:"class"
						})
					})
				})
			},
			getschool(){
				httpGet({
					url:'/api/school/infoByToken',
					data:{
						school_teacher_join_token:this.teachjoin_token
					}
				}).then((res)=>{
					this.school_teacher_join_token = res.result.school_teacher_join_token
				})
			}
			
		}
	}
</script>

<style>
	.persomfir{
		padding: 30rpx 0rpx 30rpx 35rpx;
		width: 100%;
	}
	.profileList{
		width: 100%;
		height: 110rpx;
		text-align: left;
		line-height:110rpx;
		position: relative;
		border-bottom: solid 1px #E7EBED;
		color: #666666;
		margin-left: 35rpx;
	}
	.input-box{
		position: fixed;
		right: 35rpx;
		color: #333333;
		font-size: 30rpx;
		text-align: right;
		line-height: 110rpx;
		height: 110rpx;
		/* flex: 1; */
		width: 100%;
		justify-content: center;
		align-items:center;
	}
	.buttomBut{
		height:120rpx;
		line-height:120rpx;
		width:100%;
		position:fixed;
		bottom:0;
		left:0;
		display: flex;
		background-color: #FFFFFF;
		justify-content: center;
		align-items:center;
	}

</style>
